const Koa = require('koa')
const bodyParser = require('koa-bodyparser')
const logger = require('koa-logger')
const helmet = require('koa-helmet')
const db = require(__dirname + '/../models')

const app = new Koa()

app
  .use(logger())
  .use(bodyParser())
  .use(helmet())

require('./routes')(app)

const port = 1234
db.sequelize.authenticate().then(() => {
  app.context.db = db
  app.listen(port, () => console.log(`✅  The server is running at http://localhost:${port}/`))
})
